# -*- coding:utf-8 -*-
# Created by Myth on 3/14/2018.


def use_split():
    """ string split分隔函数的用法 """
    some_number = input("Input the number split by ,")
    number_list = some_number.split(",")
    return number_list


def get_extension_name():
    """ 获得文件的扩展名 """
    file_name = input("Input file name: ")
    extension = "No Extention Name"
    i = 0
    l = len(file_name)
    # 考虑到文件名可能包含多个. 所以最后一个.后面的名称是扩展名
    while i < l:
        if file_name[i] == ".":
            i += 1
            extension = ""
            while i < l and file_name[i] != ".":
                extension += file_name[i]
                i += 1
        else:
            i += 1
    return extension


def get_extension_name_2():
    file_name = input("Input file name: ")
    list = file_name.split(".")
    return list[-1]  # 最后一个.后面的内容


def use_format(n):
    s = str(n)
    ss = "{}{}".format(s, s)
    sss = "{}{}{}".format(s, s, s)
    print(int(s) + int(ss) + int(sss))


def gcd(a, b):
    """ 辗转相除法——最大公约数 非递归算法"""
    if a > b:
        max_num = a
        min_num = b
    else:
        max_num = b
        min_num = a

    r1 = max_num % min_num

    while r1 != 0:
        r1 = max_num % min_num
        if r1 == 0:
            return min_num
        else:
            r2 = min_num % r1
            if r2 == 0:
                return r1
            else:
                max_num = r1
                min_num = r2
    return "Error"

print(gcd(36, 60))
